<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<link rel="stylesheet" type="text/css" href="../../../Themes/default/easyui.css">
		<link rel="stylesheet" type="text/css" href="../../../Themes/icon.css">
		<link rel="stylesheet" type="text/css" href="../../../CSS/demo.css">
		<link rel="stylesheet" type="text/css" href="../../../CSS/common.css">
		<script type="text/javascript" src="../../../JS/jquery.min.js"></script>
		<script type="text/javascript" src="../../../JS/jquery.easyui.min.js"></script>
		<script type="text/javascript" src="../../../JS/common.js"></script>
		<script type="text/javascript" src='../../../JS/SHA-1.js'></script>
		<script type="text/javascript" src="../../../JS/BasicInfomation.js"></script>
	</head>

	<body style="padding: 0px;">
		<div class="easyui-layout" style="width:100%;height:600px;">
			<div data-options="region:'center'">
				<div>
					<table id="dg" class="table_style">
					</table>
				</div>
			</div>
		</div>
		<div id="toolbar"></div>
		<div id="dlg" class="hiddenDialog">
			<iframe id="ifrmEdit" style="width: 100%;height: 100%;" frameborder="0" scrolling="no"></iframe>
		</div>
	</body>
	<script>
		var currid = getMultiID();
		var listUrl = "";
		if(currid != undefined) {
			listUrl = RemoteLinkAddress + "/market/boost/listbytenant.do?" + constructSpecialCondition(currid);
		} else {
			listUrl = RemoteLinkAddress + "/market/boost/list.do";
		}
		var content = "";
		var DialogWidth = 800;
		var DialogHeight = 300;
		var AddDialog;
		content = AddToolBar(99 + TOOLBAR_LOAD);
		$("#toolbar").append(content);
		
		getDataGrid();
		
		/*添加信息*/
		function newdata() {
			var pLocation = "BoothManagementAdd.html?id=-1";
			$("#ifrmEdit").attr("src", pLocation);
			constructDialog($("#dlg"), "摊位信息新增", DialogWidth, DialogHeight);
			AddDialog.dialog('open');
		}

		/*编辑信息*/
		function editdata() {
			var pLocation = "";
			var row = $('#dg').datagrid('getSelected');
			if(!row) {
				$.messager.alert('Info', "请选择你需要修改数据");
				return;
			}
			pLocation = "BoothManagementAdd.html?id=" + row.ID;
			$("#ifrmEdit").attr("src", pLocation);
			constructDialog($("#dlg"), "摊位信息修改", DialogWidth, DialogHeight);
			AddDialog.dialog('open');
		}

		//导出
		function loaddata() {
			if(currid === AddFlag) {
				$.messager.alert("警告", "该订单为新增订单，无法导出Excel！");
				return;
			}
			$.messager.confirm("提示", "确认导出Excel表格吗？", function(r) {
				if(r) {
					$.ajax({ //调用ajax方法，从服务器获取到该订单的所有数据
						type: "get",
						url: RemoteLinkAddress + "/market/boost/excel.do",
						dataType: "json", //服务器返回的数据类型
						success: function(result) {
							window.location.href = result.path;
						}, //请求成功后，接受服务器传来的Json字符串，并做相应的处理
						error: function(xhr, status, error) {
							$.messager.alert("错误", "请求失败!");
						}
					});
				}
			});
		}

		function redodata() {
			var _url = listUrl;
			$.ajax({
				dataType: "json",
				type: "get",
				url: _url,
				success: function(result) {
					if(result != null) {
						var _data = result;
						$('#dg').datagrid('loadData', _data);
					}
				},
				error: function(xhr, status, error) {
					$.messager.alert("错误", "请求失败!");
				}
			});
		}

		/*查看更多信息*/
		function findmore() {
			var row = $('#dg').datagrid('getSelected');
			if(!row) {
				$.messager.alert('提示信息', '未选中数据!');
				return;
			}
			var pLocation = "UI/Market/BoothManagement/BoothManagement.html?id=" + row.ID;
			AddTabIn("摊位相关信息", parent.parent.$("#tabs"), pLocation);
		}

		function dialogClose() {
			AddDialog.dialog('close');
		}

		function getDataGrid() {

			$('#dg').datagrid({
				url: listUrl,
				toolbar: '#toolbar',
				method: 'get',
				pagination: 'true',
				rownumbers: 'true',
				autoRowHeight: 'true',
				fitColumns: 'false',
				singleSelect: 'true',
				height: 350,
				/*表格中的列名以及各自列名的ID*/
				columns: [
					[{
							field: 'ID',
							title: 'ID',
							width: '0%',
							align: 'center'
						},

						{
							field: 'BOOST_NO',
							title: '摊位编号',
							width: '10%',
							align: 'center'
						}, {
							field: 'REGION_TYPE',
							title: '区域类型',
							width: '13%',
							align: 'center'
						}, {
							field: 'REGION_NAME',
							title: '区域名称',
							width: '14%',
							align: 'center'
						}, {
							field: 'HOUSE_NUMBER',
							title: '摊位门牌号',
							width: '13%',
							align: 'center'
						}, {
							field: 'AREA',
							title: '摊位面积',
							width: '10%',
							align: 'center',
							formatter: function(value, row, index) {
								if(value) {
									return value + '㎡';
								}
							}
						}, {
							field: 'CHARGER',
							title: '负责人',
							width: '8%',
							align: 'center'
						},
						{
							field: 'STATE',
							title: '摊位状态',
							width: '8%',
							align: 'center'
						},{
							field: 'CHARGER_TEL',
							title: '负责人电话',
							width: '14%',
							align: 'center'
						}, {
							field: 'ISVERIFY',
							title: '审核状态',
							width: '10%',
							align: 'center',
							formatter: function(value, row, index) {
								if(value == 1) {
									return "已审核";
								} else {
									return "未审核";
								}
							}
						}
					]
				],
				onDblClickRow: function(index, row) {
					console.log(row.ID);
					var pLocation = "BoothManagementAdd.html?id=" + row.ID;
					$("#ifrmEdit").attr("src", pLocation);
					constructDialog($("#dlg"), "摊位信息修改", DialogWidth, DialogHeight);
					AddDialog.dialog('open');
				}
			});
		}
		$('#dg').datagrid('hideColumn', 'ID');
		$('#dg').datagrid('hideColumn', 'BOOST_NO');
		

		//		function moreinfo(gid) {
		//			var pTitle = "摊位详细信息";
		//			if(parent.parent.$('#tabs').tabs('exists', pTitle)) {
		//				parent.parent.$('#tabs').tabs('select', pTitle);
		//			} else {
		//				var pSrc = "";
		//				pSrc = "<iframe scrolling='auto' frameborder='0'  src='UI/Market/BoothManagement/BoothManagement.html?id=" + gid + "' style='width:100%;height:100%;'></iframe>";
		//				parent.parent.$('#tabs').tabs("add", { //获取到父窗体信息
		//					title: pTitle,
		//					content: pSrc,
		//					closable: true
		//				});
		//			}
		//		}
	</script>

</html>